package top.jiangqiang.qianyi.common.base.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import org.dromara.hutool.core.date.DateFormatPool;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author JiangQiang
 * @since 2022-07-31
 */
@Data
@Accessors(chain = true)
@Schema(name = "响应数据公共字段", description = "响应数据公共字段")
public abstract class BaseEntityResponse implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "主键")
    protected Long id;
    @Schema(description = "创建人")
    protected Long createBy;
    @Schema(description = "最近修改人")
    protected Long updateBy;
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @DateTimeFormat(pattern = DateFormatPool.NORM_DATETIME_PATTERN)
    @Schema(description = "创建时间", pattern = DateFormatPool.NORM_DATETIME_PATTERN)
    protected LocalDateTime createAt;
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @DateTimeFormat(pattern = DateFormatPool.NORM_DATETIME_PATTERN)
    @Schema(description = "最近更新时间", pattern = DateFormatPool.NORM_DATETIME_PATTERN)
    protected LocalDateTime updateAt;

}
